/**
 * 
 */
package com.nwpusp.controller.actions;

import com.nwpusp.model.GameModel;
import com.nwpusp.model.players.Player;
import com.nwpusp.model.players.Player.PlayerStatus;
import com.nwpusp.model.session.ConnectionId;

/**
 * @author JustinCao
 *
 */
public class GameProcessAction extends Action {
	
	public enum ProcessType {none, start, ready, stop}
	private ProcessType type = ProcessType.none;
	private ConnectionId cid = null;
	public GameProcessAction(ProcessType type) {
		this.type = type;
	}
	
	public void setConnectionId(ConnectionId cid) {
		this.cid = cid;
	}
	
	@Override
	public void Invoke(GameModel m) {
		switch(this.type) {
			case start:
				// Player p1 = m.getPlayerManager().;
				// p1.setStatus(Player.PlayerStatus.playing);
				// m.getScenario().arrangeAllCharacters();
				m.startLocalGame();
				break;
			case stop:
				Player p2 = m.getPlayerManager().getLocalPlayer();
				p2.setStatus(Player.PlayerStatus.over);
				m.stopLocalGame();
				break;
			case ready:
				if(cid != null) {
					Player p = m.getPlayerManager().getPlayer(cid);
					if(p != null) {
						p.setStatus(Player.PlayerStatus.ready);
					}
				}
				break;
			default:
				break;
		}
	}
}
